

library(MASS)

source("1.1.1 Est.R");  source("1.1.2 Est.R")
source("1.3.1 ACEst.R"); source("1.3.2 eXEst.R"); source("1.3.3 KEst.R")

# load data
load("sample-data.RData")
# Y: outcome
# Z: treatment
# X: true covariates
# W: misspecified covariates
# N: sample size

models.cand     <- c("Both correct", "OR correct", "PS correct", "Both wrong")
Estimators.cand <- c("HT","Ratio","DR","Imb")

Results = array(NA,c(length(models.cand),length(Estimators.cand)))
dimnames(Results) = list(models = models.cand, Estimator = Estimators.cand)

Results["Both correct",] = ACEst(Z,X,X,Y,N)
Results["OR correct",]   = ACEst(Z,W,X,Y,N)
Results["PS correct",]   = ACEst(Z,X,W,Y,N)
Results["Both wrong",]   = ACEst(Z,W,W,Y,N)

# The true ATE is 17.208

print(Results)

